*12345678901234567890123456789012345678901234567890123456789012345678901234567890
capture log close
clear all
set more off

*	************************************************************************
* 	File-Name: 	ReplicationDalitAnalysis.do
*	Date:  		12/04/2019
*	Author: 	Michaël Aklin, Chao-yo Cheng, Johannes Urpelainen
*	Data Used:  ReplicationDalitData.dta
*	Output		na
*	Purpose:   	.do file to replicate the regressions in:
*				
*					Aklin, Michaël, Chao-yo Cheng, and Johannes Urpelainen.
*					"Inequality in Policy Implementation: Caste and 
*					Electrification in Rural India" Journal of Public Policy
*
*				Please reach out to the corresponding authors for code to
*				replicate the appendix results.
*	************************************************************************


*	************************************************************************
*	A. Coding do file
*	************************************************************************

* CHANGE YOUR PATH HERE
use "./ReplicationDalitData.dta", clear


*	************************************************************************
* 	B. Tables
*	************************************************************************

*	************************************************************************
* 	Table 1
*	************************************************************************

eststo: reg rggvy sharescst if year == 2002, vce(cluster lc01_con_id)
eststo: reg rggvy sharescst logdistance if year == 2002, vce(cluster lc01_con_id)
eststo: reg rggvy sharescst domelec_2001 if year == 2002, vce(cluster lc01_con_id)
eststo: reg rggvy sharescst logpop if year == 2002, vce(cluster lc01_con_id)
eststo: reg rggvy sharescst blacktoppedpuccaroadstatusa1na2 if year == 2002, vce(cluster lc01_con_id)
eststo: reg rggvy sharescst logdistance domelec_2001 logpop blacktoppedpuccaroadstatusa1na2 if year == 2002, vce(cluster lc01_con_id)
esttab using "Table1_A.tex"	///
	,  booktabs label replace ///
 	nodepvars se(2) b(2) ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	compress nogaps r2(2)  ///
	nomtitles scalars("N_clust \# Clusters") sfmt(%9.0f)
eststo clear

eststo: xtreg rggvy sharescst if year == 2002, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg rggvy sharescst logdistance if year == 2002, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg rggvy sharescst domelec_2001 if year == 2002, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg rggvy sharescst logpop if year == 2002, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg rggvy sharescst blacktoppedpuccaroadstatusa1na2 if year == 2002, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg rggvy sharescst logdistance domelec_2001 logpop blacktoppedpuccaroadstatusa1na2 if year == 2002, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace

esttab using "Table1_B.tex"	///
	,  booktabs label replace ///
 	nodepvars se(2) b(2) ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	compress nogaps r2(2)  ///
	nomtitles scalars("N_clust \# Clusters" "hhfe Constituency FE") sfmt(%9.0f)
eststo clear

*	************************************************************************
* 	Table 2
*	************************************************************************

eststo: xtreg rggvy sharescst if year == 2002 & domelec_2001 == 0, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg rggvy sharescst logdistance if year == 2002 & domelec_2001 == 0, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg rggvy sharescst logpop if year == 2002 & domelec_2001 == 0, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg rggvy sharescst blacktoppedpuccaroadstatusa1na2 if year == 2002 & domelec_2001 == 0, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg rggvy sharescst logdistance logpop blacktoppedpuccaroadstatusa1na2 if year == 2002 & domelec_2001 == 0, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace

eststo: xtreg rggvy sharescst if year == 2002 & domelec_2001 == 100, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg rggvy sharescst logdistance if year == 2002 & domelec_2001 == 100, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg rggvy sharescst logpop if year == 2002 & domelec_2001 == 100, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg rggvy sharescst blacktoppedpuccaroadstatusa1na2 if year == 2002 & domelec_2001 == 100, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg rggvy sharescst logdistance logpop blacktoppedpuccaroadstatusa1na2 if year == 2002 & domelec_2001 == 100, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace

esttab using "Table2.tex"	///
	,  booktabs label replace ///
 	nodepvars se(2) b(2) ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	compress nogaps r2(2)  ///
	nomtitles scalars("N_clust \# Clusters" "hhfe Constituency FE") sfmt(%9.0f)	///
	mgroups("Unelectrified in 2001" "Electrified in 2001", pattern(1 0 0 0 0 1 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) eqlabels(none)
eststo clear

*	************************************************************************
* 	Table 3
*	************************************************************************

eststo: reg light_elec sharescst if year == 2007, vce(cluster lc01_con_id)
eststo: reg light_elec sharescst logdistance if year == 2007, vce(cluster lc01_con_id)
eststo: reg light_elec sharescst domelec_2001 if year == 2007, vce(cluster lc01_con_id)
eststo: reg light_elec sharescst logpop if year == 2007, vce(cluster lc01_con_id)
eststo: reg light_elec sharescst blacktoppedpuccaroadstatusa1na2 if year == 2007, vce(cluster lc01_con_id)
eststo: reg light_elec sharescst logdistance domelec_2001 logpop blacktoppedpuccaroadstatusa1na2 if year == 2007, vce(cluster lc01_con_id)
esttab using "Table3_A.tex"	///
	,  booktabs label replace ///
 	nodepvars se(2) b(2) ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	compress nogaps r2(2)  ///
	nomtitles scalars("N_clust \# Clusters") sfmt(%9.0f)
eststo clear

eststo: xtreg light_elec sharescst if year == 2007, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg light_elec sharescst logdistance if year == 2007, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg light_elec sharescst domelec_2001 if year == 2007, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg light_elec sharescst logpop if year == 2007, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg light_elec sharescst blacktoppedpuccaroadstatusa1na2 if year == 2007, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace
eststo: xtreg light_elec sharescst logdistance domelec_2001 logpop blacktoppedpuccaroadstatusa1na2 if year == 2007, fe vce(cluster lc01_con_id)
	estadd local hhfe "$\checkmark$" , replace

esttab using "Table3_B.tex"	///
	,  booktabs label replace ///
 	nodepvars se(2) b(2) ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	compress nogaps r2(2)  ///
	nomtitles scalars("N_clust \# Clusters" "hhfe Constituency FE") sfmt(%9.0f)
eststo clear

*	************************************************************************
* 	Table 4
*	************************************************************************

* All
eststo: reg rggvy bsp_first if bsp_top2 == 1 & margin < 1, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first ed2 if bsp_top2 == 1 & margin < 1, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first ed2 bspmargin if bsp_top2 == 1 & margin < 1, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first ed2 bspmargin bspwin_x_running if bsp_top2 == 1 & margin < 1, vce(cluster lc01_con_id)

eststo: reg rggvy bsp_first if bsp_top2 == 1 & margin < 2, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first ed2 if bsp_top2 == 1 & margin < 2, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first ed2 bspmargin if bsp_top2 == 1 & margin < 2, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first ed2 bspmargin bspwin_x_running if bsp_top2 == 1 & margin < 2, vce(cluster lc01_con_id)

eststo: reg rggvy bsp_first if bsp_top2 == 1 & margin < 5, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first ed2 if bsp_top2 == 1 & margin < 5, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first ed2 bspmargin if bsp_top2 == 1 & margin < 5, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first ed2 bspmargin bspwin_x_running if bsp_top2 == 1 & margin < 5, vce(cluster lc01_con_id)
esttab using "Table4.tex"	///
	,  booktabs label replace ///
 	nodepvars se(2) b(2) ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	compress nogaps r2(2)  ///
	nomtitles scalars("N_clust \# Clusters") sfmt(%9.0f)	///
	mgroups("Margin$<$1\%" "Margin$<$2\%" "Margin$<$5\%", pattern(1 0 0 0 1 0 0 0 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) eqlabels(none)
eststo clear

*	************************************************************************
* 	Table 5
*	************************************************************************

eststo: reg rggvy bsp_first bspfirst_x_sharescst sharescst if bsp_top2 == 1 & margin < 1, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first bspfirst_x_sharescst sharescst ed2 if bsp_top2 == 1 & margin < 1, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first bspfirst_x_sharescst sharescst ed2 bspmargin if bsp_top2 == 1 & margin < 1, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first bspfirst_x_sharescst sharescst ed2 bspmargin bspwin_x_running if bsp_top2 == 1 & margin < 1, vce(cluster lc01_con_id)

eststo: reg rggvy bsp_first bspfirst_x_sharescst sharescst if bsp_top2 == 1 & margin < 2, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first bspfirst_x_sharescst sharescst ed2 if bsp_top2 == 1 & margin < 2, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first bspfirst_x_sharescst sharescst ed2 bspmargin if bsp_top2 == 1 & margin < 2, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first bspfirst_x_sharescst sharescst ed2 bspmargin bspwin_x_running if bsp_top2 == 1 & margin < 2, vce(cluster lc01_con_id)

eststo: reg rggvy bsp_first bspfirst_x_sharescst sharescst if bsp_top2 == 1 & margin < 5, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first bspfirst_x_sharescst sharescst ed2 if bsp_top2 == 1 & margin < 5, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first bspfirst_x_sharescst sharescst ed2 bspmargin if bsp_top2 == 1 & margin < 5, vce(cluster lc01_con_id)
eststo: reg rggvy bsp_first bspfirst_x_sharescst sharescst ed2 bspmargin bspwin_x_running if bsp_top2 == 1 & margin < 5, vce(cluster lc01_con_id)
esttab using "Table5.tex"	///
	,  booktabs label replace ///
 	nodepvars se(2) b(2) ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	compress nogaps r2(2)  ///
	nomtitles scalars("N_clust \# Clusters") sfmt(%9.0f)	///
	mgroups("Margin$<$1\%" "Margin$<$2\%" "Margin$<$5\%", pattern(1 0 0 0 1 0 0 0 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) eqlabels(none)
eststo clear




